/**
 * @author kevinlaizhiyu@foxmail.com
 * @description sport skill model
 * @date 2024-6-4
 * @version 1.0.0
 */
import mongoose, {Schema} from "mongoose";

const {ObjectId} = mongoose.Types;

export const enum SPORT_CATEGORY_TYPE_ENUM {
    TENNIS = 10,
    BADMINTON = 22,
    RUN = 30,
    OTHER = 40,
}

export interface ISportSkill {
    sportCategoryId: String;
    sportCategoryName: string;
    sportCategoryType: SPORT_CATEGORY_TYPE_ENUM;
    createdAt: number;
    updatedAt: number;
}

const sportSkillSchema = new Schema({
    sportCategoryId: {
        type: String,
        default: () => new ObjectId(),
        index: true,
        unique: true,
    }, // 技能ID
    sportCategoryName: {type: String, required: true}, // 运动项目
    sportCategoryType: {
        type: Number,
        enum: [SPORT_CATEGORY_TYPE_ENUM.TENNIS, SPORT_CATEGORY_TYPE_ENUM.BADMINTON, SPORT_CATEGORY_TYPE_ENUM.RUN, SPORT_CATEGORY_TYPE_ENUM.OTHER],
        default: SPORT_CATEGORY_TYPE_ENUM.OTHER,
    },
    createdAt: {type: Number, default: Date.now}, // 创建时间
    updatedAt: {type: Number, default: Date.now}, // 更新时间
});

const SportCategoryModel = mongoose.model("sportCategories", sportSkillSchema);

export default SportCategoryModel;
